/**
 * 本地栈缓存
 * @param n
 * @param m
 * @constructor
 */
function LeopardStack(n, m) {
	this.iMax = m;
	this.name = n;
};
/**
 * 入栈
 * @param o
 * @returns {string}
 */
LeopardStack.prototype.push = function(o) {
	var s = new LeopardStorage('stack');
	if (this.iMax) {
		var a = s.get(this.name);
		if (a && a.length >= this.iMax) {
			for (var i = 0; i < (a.length - this.iMax + 1); i ++) {
				s.del(this.name, a[i].index);
			}
		}
	}
	return s.add(this.name, o);
};
/**
 * 出栈
 * @returns {*}
 */
LeopardStack.prototype.poll = function() {
	var s = new LeopardStorage('stack');
	var a = s.get(this.name);
	if (a) {
		var o = a[a.length - 1];
		s.del(this.name, o.index);
		return o;
	} else {
		return null;
	}
};
/**
 * 删除栈
 */
LeopardStack.prototype.lose = function() {
	new LeopardStorage('stack').rmv(this.name);
};
/**
 * 查找栈中的一项数据
 * @param i
 * @returns {{index, value}}
 */
LeopardStack.prototype.find = function(i) {
	return new LeopardStorage('stack').sel(this.name, i);
};
/**
 * 栈大小
 * @returns {number}
 */
LeopardStack.prototype.size = function() {
	var a = new LeopardStorage('stack').get(this.name);
	return a ? a.length : 0;
};
/**
 * 列出栈中所有数据
 * @returns {*}
 */
LeopardStack.prototype.list = function() {
	return new LeopardStorage('stack').get(this.name);
};